package luna.com.firefly.service.business;

import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import luna.com.firefly.entity.business.WebPicture;
import luna.com.firefly.repository.business.WebPictureDao;
import luna.com.firefly.utils.jpa.PageUtil;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

/**
 * <图片接口>
 * 
 * @author 陆小凤
 * @version [1.0 2014-1-8]
 * 
 */

@Component
@Transactional(value = "transactionManager")
public class WebPictureService
{
    
    @Autowired
    private WebPictureDao picturecDao;
    
    /**
     * <查询图片列表>
     * 
     * @param type
     * @param value
     * @return
     * @see [类、类#方法、类#成员]
     */
    public Page<WebPicture> getPicList(Map<String, Object> searchParams, int pageNumber, int pageSize)
    {
        String[] orderBy = {"type"};
        PageRequest pageRequest = PageUtil.buildPageRequest(pageNumber, pageSize, "asc", orderBy);
        Specification<WebPicture> spec = PageUtil.buildSpecification(searchParams, WebPicture.class);
        return picturecDao.findAll(spec, pageRequest);
    }
    
    /**
     * <保存网络图片信息>
     * 
     * @param entity
     */
    public void savePic(WebPicture entity)
    {
        picturecDao.save(entity);
    }
    
    /**
     * <删除网络图片信息>
     * 
     * @param id
     */
    public void deletePic(Long id)
    {
        picturecDao.delete(id);
    }
    
}
